﻿<UserControl x:Class="Microsoft.Research.ScientificWorkflow.ManagementStudioControls.WorkflowManagerModule.ScheduledJobsListView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" AutomationProperties.AutomationId="ScheduledWorkflowsControl"
    xmlns:converters="clr-namespace:Microsoft.Research.ScientificWorkflow.ManagementStudioControls.WorkflowManagerModule"
    xmlns:Controls="clr-namespace:Microsoft.Research.ScientificWorkflow.UIDesigner;assembly=Microsoft.Research.ScientificWorkflow.UIDesigner">
    <UserControl.Resources>
        <ContextMenu x:Key="EmptyContextMenu"/>
        <BooleanToVisibilityConverter x:Key="VisibilityConverter"></BooleanToVisibilityConverter>
        <converters:DateTimeConverter x:Key="DateTimeConverter"></converters:DateTimeConverter>
    </UserControl.Resources>
    <Grid>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="25"/>
                <RowDefinition Height="36"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Border CornerRadius="5,5,0,0" Grid.Row="1">
                <Border.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FFFBFBFB" Offset="0"/>
                        <GradientStop Color="#FFF0F0F0" Offset="1"/>
                    </LinearGradientBrush>
                </Border.Background>
                <Grid>
                    <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
                        <Button Command="{Binding Path=EditScheduleCommand}" CommandParameter="{Binding ElementName=DisplayListView, Path=SelectedItem}" Style="{DynamicResource editScheduleButton}" Width="26" Height="26" ToolTip="Edit" Margin="5,0,0,0" AutomationProperties.AutomationId="EditScheduleButton"/>
                        <Button Command="{Binding Path=DeleteScheduleCommand}" CommandParameter="{Binding ElementName=DisplayListView, Path=SelectedItem}" Style="{DynamicResource deleteButton}" Width="26" Height="26" ToolTip="Delete" Margin="5,0,0,0" AutomationProperties.AutomationId="DeleteScheduleButton"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                        <Button Style="{DynamicResource refreshButton}" Margin="0,0,10,0" Width="24" Height="24" Command="{Binding Path=RefreshListCommand}" ToolTip="Refresh" AutomationProperties.AutomationId="RefreshScheduleButton"></Button>
                    </StackPanel>
                </Grid>
            </Border>

            <Grid Grid.Row="2" Margin="5,10,5,5" Grid.RowSpan="2">
                <Controls:SortListView KeyDown="DisplayListView_KeyDown" SelectionMode="Single" SelectedIndex="{Binding Path=SelectedIndex}" Style="{DynamicResource ListViewStyle1}" ItemsSource="{Binding Path=Items}" ScrollViewer.CanContentScroll="True" x:Name="DisplayListView" IsSynchronizedWithCurrentItem="True" ItemTemplate="{DynamicResource ParentDataTemplate}" Width="Auto" Height="Auto" >
                    <Controls:SortListView.ItemContainerStyle>
                        <Style TargetType="{x:Type ListViewItem}">
                            <Setter Property="Template" Value="{DynamicResource ListViewItemControlTemplate1}"/>
                            <Setter Property="ContextMenu" Value="{StaticResource EmptyContextMenu}"/>
                            <EventSetter Event="ContextMenuOpening" Handler="ContextMenu_ContextMenuOpening"></EventSetter>
                            <EventSetter Event="MouseDoubleClick" Handler="ListViewItemDoubleClicked"></EventSetter>
                        </Style>
                    </Controls:SortListView.ItemContainerStyle>
                    <Controls:SortListView.View>
                        <GridView>
                            <Controls:SortListViewColumn SortByDefault="True" DefaultSortDirection="Ascending" MinimumWidth="120" SortProperty="JobName" Header="Job Name" DisplayMemberBinding="{Binding Path=JobName}" />
                            <Controls:SortListViewColumn MinimumWidth="120" SortProperty="WorkflowName" Header="Workflow Name" DisplayMemberBinding="{Binding Path=WorkflowName}" />
                            <Controls:SortListViewColumn MinimumWidth="110" Width="110" SortProperty="ScheduledBy" Header="Scheduled By" DisplayMemberBinding="{Binding Path=ScheduledBy}" />
                            <Controls:SortListViewColumn MinimumWidth="100" Width="100" SortProperty="ScheduleType" Header="Schedule Type" DisplayMemberBinding="{Binding Path=ScheduleType}"/>
                            <Controls:SortListViewColumn MinimumWidth="100" SortProperty="NodeName" Width="120" Header="Node" DisplayMemberBinding="{Binding Path=NodeName}" />
                            <Controls:SortListViewColumn MinimumWidth="130" Width="130" SortProperty="StartTime" Header="Start Date" DisplayMemberBinding="{Binding Path=StartTime}"/>
                            <Controls:SortListViewColumn MinimumWidth="130" Width="130" SortProperty="EndTime" Header="End Date" DisplayMemberBinding="{Binding Path=EndTime, Converter={StaticResource DateTimeConverter}}"/>
                            <Controls:SortListViewColumn Header="Details" DisplayMemberBinding="{Binding Path=Description}"/>
                        </GridView>
                    </Controls:SortListView.View>
                </Controls:SortListView>
                <Grid Background="White" Visibility="{Binding Converter={StaticResource VisibilityConverter}, Path=EmptyList}" Width="{Binding Path=Width, ElementName=ListviewHost}" Height="{Binding Path=Height, ElementName=ListviewHost}">
                    <TextBlock HorizontalAlignment="Center" Foreground="Gray">No Items to be shown</TextBlock>
                </Grid>
            </Grid>
            <Border Margin="0,0,0,0" CornerRadius="5,5,0,0" BorderThickness="0,0,0,1" BorderBrush="#FFFFFFFF">
                <Border.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FFFFFFFF" Offset="0"/>
                        <GradientStop Color="#FFE8E8E8" Offset="1"/>
                    </LinearGradientBrush>
                </Border.Background>
                <TextBlock Text="{Binding Path=ListViewTitle}" TextWrapping="Wrap" FontSize="14" FontWeight="Normal" Margin="7,2,0,0"/>
		</Border>
        </Grid>
    </Grid>
</UserControl>
